import { config, Base_Api } from '../../config/index';

/** 获取商品列表 */
function mockFetchGoodCategory() {
  const { delay } = require('../_utils/delay');
  const { getCategoryList } = require('../../model/category');
  return delay().then(() => getCategoryList());
}

/** 获取商品列表 */
// export function getCategoryList() {
//   if (config.useMock) {
//     return mockFetchGoodCategory();
//   }
//   return new Promise((resolve) => {
//     resolve('real api');
//   });
// }



export function getCategoryListItems(data) {
  return new Promise((resolve, reject) => {
    wx.request({
      url: Base_Api + "/get_categoryItems",
      method: "POST",
      data,
      success: (res) => {
        resolve(res)
      },
      fail: (err) => {
        reject(err)
      }
    })
  })

}


export function getCategoryList() {
  return new Promise((resolve, reject) => {
    wx.request({
      url: Base_Api + "/get_category",
      method: "POST",
      success: (res) => {
        resolve(res)
      },
      fail: (err) => {
        reject(err)
      }
    })
  })

}

